#include <iostream>

int main() {
    int arr[3][3], transposed[3][3];
    std::cout << "输入一个3*3的二维数组: ";
    
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            std::cin >> arr[i][j];
        }
    }
    
    // Transpose the array
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            transposed[i][j] = arr[j][i];
        }
    }
    
    std::cout << "转置后的二维数组: \n";
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            std::cout << transposed[i][j] << " ";
        }
        std::cout << std::endl;
    }
    
    // Sum of diagonal elements
    int diagonal_sum = 0;
    for (int i = 0; i < 3; ++i) {
        diagonal_sum += transposed[i][i] + transposed[i][2 - i];
    }
    
    std::cout << "转置后的二维数组的对角线元素之和: " << diagonal_sum << std::endl;
    
    return 0;
}